package com.example.controller;

import com.example.service.PersonService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;


@Controller
public class GreetingController {

    @Resource
    public PersonService personService;

    @RequestMapping("/")
    public String index(){
        return "index";
    }

    @RequestMapping("/greeting")
    public String greeting(@RequestParam(value = "name" ,required = false,defaultValue = "World") String name, Model model) {
        model.addAttribute("name", personService.findAll());
        return "greeting";
    }

}
